package com.qdu.driver;
import com.qdu.bean.bikeWritable;
import com.qdu.mapper.RentByTempMapper;
import com.qdu.reducer.RentByTempReducer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class RentByTempDriver {
    public static void main(String[] args) throws InterruptedException, IOException, ClassNotFoundException {
        args = new String[] { "D:/train.csv", "D:/output1" };
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);

        job.setJarByClass(RentByTempDriver.class);

        job.setMapperClass(RentByTempMapper.class);
        job.setReducerClass(RentByTempReducer.class);

        job.setMapOutputKeyClass(DoubleWritable.class);
        job.setMapOutputValueClass(bikeWritable.class);

        job.setOutputKeyClass(DoubleWritable.class);
        job.setOutputValueClass(bikeWritable.class);

        FileInputFormat.addInputPath(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[1]));

        boolean result = job.waitForCompletion(true);
        System.exit(result ? 0 : 1);
    }
}
